package com.teradata.handle;


import com.teradata.entities.Result;
import com.teradata.enums.ResultEnum;
import com.teradata.utils.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @ControllerAdvice 拦截所有controller请求
 * @ResponseBody 返回Json
 */
@ControllerAdvice
public class ExceptionHandle {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handle(Exception e){
        return ResultUtil.error(ResultEnum.UNKNOWN_ERROR);
    }
}
